import React, {Component} from 'react';
import {ThemesContext} from "../Demo2/ButtonContext";

const  FooContext = React.createContext({name: "Alice"})
class Demo3 extends Component {
    render() {
        return (
            <div>
                <FooContext.Provider value={{name: 'Lucy'}}>
                    <Foo/>
                </FooContext.Provider>
            </div>
        );
    }
}

export default Demo3;


function Foo(props){
    return(
        <FooContext.Consumer>
            {
                value => <h1>{value.name}</h1>
            }
        </FooContext.Consumer>
        )
}